//
//  PromiseLabel.m
//  JiaoX
//
//  Created by yinqy on 15/1/12.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import "PromiseLabel.h"
#define LABEL_FONT_SIZE [DimensUtils getScaleX:12]

@interface PromiseLabel()
{
    UIImageView *imageView;
    UILabel *label;
}

@end
@implementation PromiseLabel

- (instancetype)initWithLabelText:(NSString *)text
{
    self = [super init];
    if (self) {
        
        CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:LABEL_FONT_SIZE]];
        imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ic_promise"]];
        imageView.x = size.width+7.5;
        [self addSubview:imageView];
        
        label = [[UILabel alloc]init];
        [label setTextColor:JXColor(102, 102, 102)];
        [label setFrame:CGRectMake(7.5, (imageView.image.size.height-size.height)/2, size.width, size.height)];
        [label setText:text];
        [label setFont:[UIFont systemFontOfSize:LABEL_FONT_SIZE]];
        [self addSubview:label];
        
        [self setBounds:CGRectMake(0, 0, 7.5+size.width+imageView.image.size.width, imageView.image.size.height)];
        
        //设置layer
        CALayer *layer=[self layer];
        //是否设置边框以及是否可见
        [layer setMasksToBounds:YES];
        //设置边框线的宽
        [layer setBorderWidth:0.5];
        //设置边框线的颜色
        [layer setBorderColor:[JXColor(255, 127, 187) CGColor]];
    }
    return self;
}
@end
